package com.wujilee.wujileejuc.aqs;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author liwuji
 * @date 2024/7/8
 * @desc
 **/
public class ReentrantLockTest {
    private static final Lock lock = new ReentrantLock();
    private static final Condition condition = lock.newCondition();


    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            lock.lock();
            try {

                // 业务判断 不符合的时候等待 -- 且释放锁
                condition.await();;
                // 条件符合的时候继续执行

            }catch (Exception e){
                e.printStackTrace();
            }
            finally {

                lock.unlock();
            }
        });
        Thread.sleep(100L);
        condition.signal();

    }
}
